package firstPack;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Circle;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;

/**
 * Runs a satirical list of my game programming 
 * achievements in a movie credit like fashion. Returns
 * back to the main menu when space is pressed.
 * State 5
 * @author El Jefe
 *
 */
public class CreditState extends BasicGameState{
	
	private int yValue;
	private String credits;
	private int timePassed;

	@Override
	public void init(GameContainer container, StateBasedGame game)
			throws SlickException {	
		yValue = 700;
		credits = 
		"     Totally sweet graphics     Anthony S\n" +
		"Super impressive game logic     Anthony S\n" +
		"    Crazy intense game play     Anthony S\n" +
		"   Gripping narrative story     Anthony S\n" +
		"High definition 3D modeling     Anthony S\n" +
		"Scientific graphic analysis     Anthony S\n" +
		"        Ruthless difficulty     Anthony S\n" +
		"  Quizzical puzzle elements     Anthony S\n";
		timePassed = 0;
	}

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics disp)
			throws SlickException {
		disp.drawString("Press space to return", 30, 30);
		disp.drawString(credits, 300, yValue);
		
	}

	@Override
	public void update(GameContainer container, StateBasedGame sbg, int delta)
			throws SlickException {
		Input input = container.getInput();
		timePassed += delta;
		if(timePassed > 10){
			timePassed = 0;
			yValue -= 1;
			if (yValue <= -150){
				yValue = 770;
			}
		}
		
		if(input.isKeyPressed(input.KEY_SPACE)){
			input.clearKeyPressedRecord();
			sbg.enterState(0, new FadeOutTransition(), new FadeInTransition());
		}
		
	}

	@Override
	public int getID() {
		// TODO Auto-generated method stub
		return 5;
	}

}
